Skip to content

Wizard/Packages: Sort packages by the newest added (HMS-10767) - #4719

Open
regexowl wants to merge 1 commit into
osbuild:mainfrom
regexowl:pkg-table-sorting
Open

Wizard/Packages: Sort packages by the newest added (HMS-10767)#4719
regexowl wants to merge 1 commit into
osbuild:mainfrom
regexowl:pkg-table-sorting

Conversation

@regexowl

@regexowl regexowl commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

This replaces original sorting logic, that was mostly leftover from the pre-revamp table focused workflow, with a simple sort by recency.

This will not touch sorting within the search, so all functionality as sorting active app stream to the top within the list of available options is still in place.

@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.11%. Comparing base (efa0143) to head (38aa41a).

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4719      +/-   ##
==========================================
+ Coverage   78.00%   78.11%   +0.11%     
==========================================
  Files         264      264              
  Lines        7069     7033      -36     
  Branches     2597     2576      -21     
==========================================
- Hits         5514     5494      -20     
+ Misses       1458     1442      -16     
  Partials       97       97              
Flag Coverage Δ
playwright 60.11% <100.00%> (-0.10%) ⬇️
vitest 73.09% <100.00%> (+0.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ImageWizard/steps/Packages/components/Packages.tsx 96.15% <ø> (ø)
...Wizard/steps/Packages/components/PackagesTable.tsx 62.31% <100.00%> (+8.98%) ⬆️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update efa0143...38aa41a. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@regexowl
regexowl marked this pull request as ready for review August 6, 2026 11:58
@regexowl
regexowl requested a review from a team as a code owner August 6, 2026 11:58
@regexowl
regexowl requested review from ksiekl, mgold1234 and ochosi August 6, 2026 11:58

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The new return [...packages].reverse(); and return [...groups].reverse(); logic assumes the incoming arrays are always ordered oldest → newest; if that’s a requirement, consider making it explicit (e.g., sorting by a timestamp field) or documenting it so future changes to the source ordering don’t silently break the “newest first” behavior.
  • Previously groups were sorted alphabetically by name, but now they are simply reversed; if the UX doesn’t explicitly call for recency-based ordering of groups, it may be worth double‑checking that reversing is intentional and not an accidental regression from the prior deterministic ordering.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `return [...packages].reverse();` and `return [...groups].reverse();` logic assumes the incoming arrays are always ordered oldest → newest; if that’s a requirement, consider making it explicit (e.g., sorting by a timestamp field) or documenting it so future changes to the source ordering don’t silently break the “newest first” behavior.
- Previously groups were sorted alphabetically by name, but now they are simply reversed; if the UX doesn’t explicitly call for recency-based ordering of groups, it may be worth double‑checking that reversing is intentional and not an accidental regression from the prior deterministic ordering.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@regexowl
regexowl marked this pull request as draft August 6, 2026 12:04
@regexowl
regexowl force-pushed the pkg-table-sorting branch 2 times, most recently from a7d46d2 to 716aa8b Compare August 12, 2026 06:52
}
};

const sortedPackages = useMemo(() => {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same sorting logic remains in PackageSearch where it still makes sense. In the case of packages table, there is no reason to sort the rows by stream, end date, etc. and thus adding the packages to the selected packages table in seemingly random places.

@regexowl
regexowl marked this pull request as ready for review August 12, 2026 07:56

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The removal of sortedGroups means package groups are now rendered in their insertion order instead of alphabetically; if group ordering is still expected to be deterministic for users, consider preserving a simple name-based sort or explicitly documenting the new behavior.
  • The reducer now relies on unshift to represent recency, but the UI doesn’t explicitly sort by a timestamp or other field; if future changes alter insertion patterns, it may be safer to encode recency in the data model rather than relying solely on array position.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The removal of `sortedGroups` means package groups are now rendered in their insertion order instead of alphabetically; if group ordering is still expected to be deterministic for users, consider preserving a simple name-based sort or explicitly documenting the new behavior.
- The reducer now relies on `unshift` to represent recency, but the UI doesn’t explicitly sort by a timestamp or other field; if future changes alter insertion patterns, it may be safer to encode recency in the data model rather than relying solely on array position.

## Individual Comments

### Comment 1
<location path="src/store/slices/wizard/content/tests/content.test.ts" line_range="66" />
<code_context>
         expect(state.content.packages.map((p) => p.name)).toEqual([
-          'vim',
-          'git',
           'curl',
+          'git',
+          'vim',
         ]);
       });
</code_context>
<issue_to_address>
**issue (testing):** Add corresponding tests for `groups` reducer to cover newest-first behaviour

The expectations for `packages` now correctly reflect the newest-first (`unshift`) behaviour. The same ordering change was applied to `groups`, but there’s no test asserting this.

Please add reducer tests for `addPackageGroup` that start from a non-empty `groups` array, add one or more groups, and verify that new groups are inserted at the beginning. This will keep coverage aligned with the reducer behaviour and guard against regressions in `groups` ordering.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

expect(state.content.packages.map((p) => p.name)).toEqual([
'vim',
'git',
'curl',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (testing): Add corresponding tests for groups reducer to cover newest-first behaviour

The expectations for packages now correctly reflect the newest-first (unshift) behaviour. The same ordering change was applied to groups, but there’s no test asserting this.

Please add reducer tests for addPackageGroup that start from a non-empty groups array, add one or more groups, and verify that new groups are inserted at the beginning. This will keep coverage aligned with the reducer behaviour and guard against regressions in groups ordering.

@regexowl

Copy link
Copy Markdown
Collaborator Author
  • The removal of sortedGroups means package groups are now rendered in their insertion order instead of alphabetically; if group ordering is still expected to be deterministic for users, consider preserving a simple name-based sort or explicitly documenting the new behavior.

Sorting by recency is intentional.

  • The reducer now relies on unshift to represent recency, but the UI doesn’t explicitly sort by a timestamp or other field; if future changes alter insertion patterns, it may be safer to encode recency in the data model rather than relying solely on array position.

Information about packages / pkg groups is stored in a flat list of names, so we need to work with that.

@regexowl
regexowl force-pushed the pkg-table-sorting branch 2 times, most recently from bc1e9d2 to 2d8be1d Compare August 12, 2026 12:52
This replaces original sorting logic, that was mostly leftover from the pre-revamp table focused workflow, with a simple sort by recency.

This will not touch sorting within the search, so all functionality as sorting active app stream to the top within the list of available options is still in place.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant